package com.bw.mapper;

import com.bw.domain.Role;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface RoleMapper {
    @Select("select  * from t_role")
    List<Role> list();

    void add(Role role);

    void addRoleMenu(@Param("roleId") Integer id,@Param("menuId") String menuId);

    @Select("select * from t_role where role_name=#{roleName}")
    Role checkRoleName(String roleName);
    @Select("select menu_id from t_role_menu where role_Id=#{roleId}")
    List<Integer> getMenuIdsByRoleId(Integer roleId);

    /***
     * 修改角色
     * @param role
     */
    @Update("update t_role set role_name=#{roleName} where id=#{id}")
    void update(Role role);

    @Delete("delete  from t_role_menu where role_id=#{roleId}")
    void deleteRoleMenu(Integer roleId);
}
